#include "StdAfx.h"
#include "sa_TwSprite.h"

sa_TwSprite::sa_TwSprite(void):
d3dspt(0)
,sprite(0)
{
}

sa_TwSprite::~sa_TwSprite(void)
{
}
void sa_TwSprite::InitGraphics()
{
	D3DXCreateSprite(g_Render->GetDevice(), &d3dspt);    // create the Direct3D Sprite object

	D3DXCreateTextureFromFile(g_Render->GetDevice(), (LPCSTR)"Panel1.png", &sprite);
}

void sa_TwSprite::InitRenderState()
{

}

void sa_TwSprite::InitLight()
{

}

void sa_TwSprite::Update()
{

}

void sa_TwSprite::Render()
{
	// clear the window to a deep blue
	g_Render->GetDevice()->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);

	g_Render->GetDevice()->BeginScene();    // begins the 3D scene

	d3dspt->Begin(NULL);    // begin sprite drawing

	// draw the sprite
	D3DXVECTOR3 center(0.0f, 0.0f, 0.0f);    // center at the upper-left corner
	D3DXVECTOR3 position(50.0f, 50.0f, 0.0f);    // position at 50, 50 with no depth
	d3dspt->Draw(sprite, NULL, &center, &position, D3DCOLOR_XRGB(255, 255, 255));

	d3dspt->End();    // end sprite drawing

	g_Render->GetDevice()->EndScene();    // ends the 3D scene

	g_Render->GetDevice()->Present(NULL, NULL, NULL, NULL);


}

void sa_TwSprite::Clear()
{
	sprite->Release();
}